<template>
	<view class="">
		<view class="backCol64aeb4 h240r disFlex aliItCenter pl20r pr20r borB1SF2f2f2"
			@click="cliLogin"
		>
			<view class="w190r ">
				<image :src="token ? '/static/icons/iconUserAvatar.png' : '/static/icons/iconHeadPortrait.png'"
					mode="aspectFill"
					class="w140r h140r borRad50P bor3Srgba2412412410s5"
				></image>
			</view>
			<view class="flex1 colFff ">
				<view class="foWeiBold f36r" v-if="!token">
					立即登录
				</view>
				<view class="" v-else>
					<view class="foWeiBold f36r">
						账户名：{{userInfo.username}}
					</view>
					<view class="f28r mt15r disFlex">
						<view class="flex1 webLiCl1 webBoxOrVer overHid disWebBox">
							保洁名：{{userInfo.name}}
						</view>
						<view class="flex1 teAliRight">
							微信：{{
								userInfo.is_bind == 1 ? '未绑定' :
								userInfo.is_bind == 2 ? '已绑定' : userInfo.is_bind
							}}
						</view>
					</view>
					<view class="f28r mt15r disFlex">
						<view class="flex1">
							茶室tid：{{userInfo.tid}}
						</view>
						<view class="flex1 teAliRight">
							账户：{{
								userInfo.type == 1 ? '已启用' :
								userInfo.type == 2 ? '已禁用' : userInfo.type
							}}
						</view>
					</view>
				</view>
			</view>
		</view>
		<button @click="cliBindWeChat" v-if="token && userInfo && userInfo.is_bind == 1"
			class="w710r lh100r teAliCenter borRad10r backCol67c23a mAuto f30r colFff mt20r"
		>
			绑定微信
		</button>
	</view>
</template>
<script>
import { inquiryToLogin } from '@/utils/utils.js'
export default {
	data() {
		return {
			token: '',
			userInfo: {},
		}
	},
	onShow() {
		this.token = '';
		this.userInfo = {};
		inquiryToLogin().then(res => {
			console.log(111, res)
			this.token = res;
			this.userInfo = uni.getStorageSync('userInfo');
		});
	},
	methods: {
		cliLogin() {
			if(this.token) {
				uni.navigateTo({ url: '/pages/personalCenter/userInformation' })
			}else {
				uni.navigateTo({ url: '/pages/personalCenter/login' })
			}
		},
		cliBindWeChat() {
			window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxa9dbb97e2b08756d&redirect_uri=https://newapi.shanqueyi.com%2FopenCleanWechatH5&response_type=code&scope=snsapi_base&state=' +
				this.token + 
				'#wechat_redirect';
		}//
	}
}

</script>
<style>
</style>